<template>
	<view>
		<hic-login
		logo="https://foster-use.oss-cn-chengdu.aliyuncs.com/icon/login.png"
		title="认养地块后台管理系统"
		:props="props"
		:thirdProps="thirdProps"
		@login="handleLogin"
		@remove="remove"
		>
		<!-- <template #bottom>
		    <view>xxxxxxx技术有限公司</view>
		    <view class="text-center">0591-88515005</view>
		</template> -->
		</hic-login>
	</view>
</template>

<script>
	import {operatorLogin} from "@/api/api.js"
	export default{
		data(){
			return {
				props: {account: 'name', password: 'pwd'},
			}
		},
		onLoad() {
			let account = uni.getStorageSync("operatorAccount")
		},
		methods:{
			async goLogin(params){
				const res = await operatorLogin(params)
				if(res?.data.code == 200){
					uni.$u.toast("登录成功")
					uni.hideLoading()
					setTimeout(()=>{
						uni.navigateTo({
							url:"/pages/operator/operator"
						})
					},1000)
					uni.setStorageSync("operatorAccount",res.data.data)
				}else{
					uni.showToast({
						title:res.data.msg,
						icon:'error'
					})
					uni.hideLoading()
				}
			},
			handleLogin(form) {
			    // 表单验证
			    console.log(form);  // {loginName: '13xxx81', password: '123'}
				uni.showLoading({
					mask:true,
				})
				this.goLogin(form)
			},
			remove(item, index) {
				console.log(item);
				uni.showModal({
			        title: '提示',
			        content: `确定删除账号${item.name}？`,
			        success: (res) => {
			            this.history.splice(index, 1);
			        }
			    });
			},
		}
	}
</script>

<style lang="scss" scoped>
	.form-input {
	    font-size: 45rpx;
	    color: $hic-login-triangle-color;
	    margin: 0 10rpx;
	}
	.cuIcon-weixin:before {
	    content: "\e612";
	}
	.text-green, .line-green, .lines-green {
	    color: #39b54a;
	}
	.text-center{
		text-align: center;
	}
</style>